﻿<Page x:Class="Topics.Radical.Samples.Validation.ValidationSamplePage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      xmlns:local="clr-namespace:Topics.Radical.Samples.Validation"
      d:DesignHeight="393" d:DesignWidth="529"
      xmlns:markup="http://schemas.topics.it/wpf/radical/windows/markup"
	  Title="{Binding Path=Title}"
      Style="{StaticResource ResourceKey=samplePage}">
    <Page.DataContext>
        <local:ValidationSampleViewModel />
    </Page.DataContext>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="70*" />
            <RowDefinition Height="30*" />
        </Grid.RowDefinitions>

<TextBox Text="{markup:EditorBinding Path=Text}" Grid.Row="0" Margin="33,47,220,0" Height="25" VerticalAlignment="Top" />

<ListBox Grid.Row="1" Grid.IsSharedSizeScope="True" ItemsSource="{Binding Path=ValidationErrors}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition SharedSizeGroup="foo" Width="Auto" />
                    <ColumnDefinition SharedSizeGroup="bar" Width="*" />
                </Grid.ColumnDefinitions>

                <TextBlock Text="{Binding Path=Key}" Margin="0,0,5,0" Grid.Column="0" Foreground="Red" />
                <TextBlock Text="{Binding}" Grid.Column="1" Foreground="Brown" />

            </Grid>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
        <TextBlock Text="This is validated while writing" HorizontalAlignment="Left" Margin="33,26,0,0" VerticalAlignment="Top"/>
        <Button Content="Click to run full validation" 
                HorizontalAlignment="Left" 
                Command="{markup:AutoCommandBinding Path=RunValidation}"
                Margin="33,77,0,0" VerticalAlignment="Top" MinWidth="75"/>

    </Grid>
</Page>
